<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>注册中心</title>
    <style type="text/css">
        td{
            height: 25px;
            width: 100px;
            border: #3a8ee6 1px solid;
            }
        input{
            height: 21px;
        }
    </style>
    <script type="text/javascript" src="js/jquery-1.11.0.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
    <script type="text/javascript">
        //添加用户
        function register() {
            var v = $("#search_form").serializeArray();
            // alert(v);
            $.ajax({
                url:"/myspringboot/registerUser",
                data:v,
                type:"post",
                dataType:"json",
                success :function (result) {
                    if(result=="SUCCESS"){
                         alert(result)
                        window.location.href="/myspringboot/static/main.html"
                    }else{
                        alert(result)
                    }
                }
            })
        }
    </script>
    <script type="text/javascript" >
        function findUsername() {
            var val = $("#uName").val();
            $.ajax({
                url:"/myspringboot/findUsername",
                data:{username:val},
                type:"post",
                dataType:"json",
                success :function (result) {
                    var code = result.code;
                    var msg = result.msg;

                    if (code==0){
                        alert(msg)
                        window.location.href="/myspringboot/static/register.html"
                    }else {
                    }

                }
            })
        }
    </script>
    <script type="text/javascript">
        function bbb() {
            var price=$("#sno").val();
            var reg=/^[0-9]{6}$/;
            var flag=reg.test(price);
            if(flag){

            }else{
                alert("邮政编码是6位数字");

            }
            return flag
        }
    </script>
    <script type="text/javascript">
        function ccc() {
            var price=$("#tel").val();
            var reg= /^((0\d{2,3}-\d{7,8})|(1[3584]\d{9}))$/;
            var flag=reg.test(price);
            if(flag){

            }else{
                alert("请输入正确的手机号码");

            }
            return flag
        }
    </script>
    <script type="text/javascript">
        function ddd() {
            var price=$("#email").val();
            var reg=/^\w+@[a-zA-Z0-9]{2,10}(?:\.[a-z]{2,4}){1,3}$/;
            var flag=reg.test(price);
            if(flag){

            }else{
                alert("请输入正确邮箱");

            }
            return flag
        }
    </script>
</head>
<body class=bg-success>
<form id="search_form">
    <div align="center">
    <table class="" style="border: 1px solid #999;border-collapse:collapse">
        <h1 align="center">注册中心</h1>
        <tr align="center">
            <td >用户名：</td>
            <td ><input id="uName" name="uName" type="text" class="form-control" onblur="findUsername()"  placeholder="请输入"></td>
            <td></td>
        </tr>
        <tr align="center">
            <td>用户类别：</td>
            <td>
                <select id="rId" name="rId" style=" height: 25px; width: 160px;">
                    <option value="">请选择</option>
                    <option value="0">管理员</option>
                    <option value="1">卫生局</option>
                    <option value="2">卫生院</option>
                    <option value="3">卫生室</option>
                    <option value="4">供货商</option>
                </select>
            </td>
            <td></td>
        </tr >
        <tr align="center">
            <td >密码：</td>
            <td ><input class="form-control" name="uPassword" type="text"
                        placeholder="请输入"></td>
            <td></td>
        </tr>
        <tr align="center">
            <td>所在单位：</td>
            <td><input  name="uCompany" type="text" class="form-control"
                        placeholder="请输入"></td>
            <td></td>
        </tr>
        <tr align="center">
            <td>联系地址：</td>
            <td><input  name="uAdress" type="text" class="form-control"
                        placeholder="请输入"></td>
            <td></td>
        </tr>
        <tr align="center">
            <td>邮政编码：</td>
            <td><input type="text" class="form-control" name="uPostalcode"  id="sno" onblur="bbb()" placeholder="请输入"></td>
            <td></td>
        </tr>
        <tr align="center">
            <td>联系人：</td>
            <td><input type="text" class="form-control" name="uContacts"
                       placeholder="请输入">
            <td></td>
        </tr>
        <tr align="center">
            <td>联系电话：</td>
            <td><input type="text" class="form-control" name="uPhone" id="tel" onblur="ccc()" placeholder="请输入"></td>
            <td></td>
        </tr>
        <tr align="center">
        <td>email：</td>
        <td><input type="text" class="form-control" name="uEmail" id="email" onblur="ddd()" placeholder="请输入"></td>
        <td></td>
        </tr>

    </table>
    <td>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="reset" align="center" onclick="register()">注册</button>
        <a href="http://localhost:8080/myspringboot/static/login.html">关闭</a>
    </td>
    <br>
</div>
</form>
<iframe id="iframe" name="rfFrame" src="about:blank" style="display:none;"></iframe>
</body>
</html>
